---
redirect_from:
  - /reference
---

# CLI command reference

## create

The `create` command generates barebones Cube app.

### Usage

```bash{promptUser: user}
npx cubejs-cli create APP-NAME -d DB-TYPE [-t TEMPLATE]
```

### Flags

| Parameter                   | Description                                  | Values                                                                                                                  |
| --------------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `-d, --db-type <db-type>`   | Preconfigure Cube app for selected database. | `postgres`, `mysql`, `athena`, `mongobi`, `bigquery`, `redshift`, `mssql`, `clickhouse`, `snowflake`, `presto`, `druid` |
| `-t, --template <template>` | Framework running Cube backend.              | `docker` (default)                                                                                                      |

### Example

Create app called `demo-app` using default (`docker`) template and `mysql`
database:

```bash{promptUser: user}
npx cubejs-cli create demo-app -d mysql
```

Create app called `demo-app` using `express` template and `mysql` database:

```bash{promptUser: user}
npx cubejs-cli create demo-app -t express -d mysql
```

## server

<WarningBox>

To define configuration you should use `cube.js` configuration file. See
[available options](/reference/configuration/config).

</WarningBox>

The `server` command starts Cube in production mode.

Default start:

```bash{promptUser: user}
npx cubejs-cli server
```

With debug information:

```bash{promptUser: user}
npx cubejs-cli server --debug
```

### Usage

```bash{promptUser: user}
npx cubejs-cli server
```

## generate

The `generate` command helps to build data models for existing database tables.
You can only run `generate` from the Cube app directory. This command requires
an active [database connection](/product/configuration/data-sources).

### Usage

```bash{promptUser: user}
npx cubejs-cli generate -t TABLE-NAMES
```

### Flags

| Parameter               | Description                                                 | Values                      |
| ----------------------- | ----------------------------------------------------------- | --------------------------- |
| `-t, --tables <tables>` | Comma delimited list of tables to generate data models for. | `TABLE-NAME-1,TABLE-NAME-2` |

### Example

Generate data model files for tables `orders` and `customers`:

```bash{promptUser: user}
npx cubejs-cli generate -t orders,customers
```

## token

The `token` command generates a JWT Cube token. It either uses the value of the
`CUBEJS_API_SECRET` environment variable or provided value with `-s` flag. You
can only run `token` command from the Cube app directory.

_Use these manually generated tokens in production with caution._ <br/> _Please
refer to the [Security Guide](/product/auth) for production security best
practices._

### Usage

```bash{promptUser: user}
npx cubejs-cli token -e TOKEN-EXPIRY -s SECRET -p FOO=BAR -u BAZ=QUX
```

### Flags

| Parameter              | Description                                                                   | Example                    |
| ---------------------- | ----------------------------------------------------------------------------- | -------------------------- |
| -e, --expiry           | Token expiry. Set to 0 for no expiry (default: "30 days")                     | `1 day`, `30 days`         |
| -s, --secret           | Cube app secret. Also can be set via environment variable `CUBEJS_API_SECRET` | -                          |
| -p, --payload          | Token Payload                                                                 | `foo=bar`, `userId=2`      |
| -u, --user-context     | Token USER_CONTEXT Payload                                                    | `baz=qux`, `companyId=5`   |

### Example

Generate token with 1 day expiry and payload `{ 'appId': 1, 'userId': 2 }`:

```bash{promptUser: user}
npx cubejs-cli token -e "1 day" -p appId=1 -p userId=2
```

## validate

The `validate` command checks models in a Cube project for validation errors.

### Usage

```bash{promptUser: user}
npx cubejs-cli validate
```

### Example

Example of a Cube project with models that fail validation:

```bash{outputLines: 2-16}
npx cubejs-cli validate
❌ Cube Schema validation failed

Cube Error ---------------------------------------

Orders cube: "dimensions.id" does not match any of the allowed types
Possible reasons (one of):
  * (dimensions.id.case) is required
  * (dimensions.id.latitude) is required
  * (dimensions.id.sql) is required
LineItems cube: Cube Orders doesn't exist

Need some help? -------------------------------------

  Ask this question in Cube Slack: https://slack.cube.dev
  Post an issue: https://github.com/cube-js/cube/issues
```
